/*
 * CTalentToolTip.java
 *
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 *
 * This file is part of JRogueDPS.
 *
 * JRogueDPS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JRogueDPS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JRogueDPS.  If not, see <http://www.gnu.org/licenses/>.
 */

package talents;

import java.util.ArrayList;

/**
 *
 * @author gmillward
 */
public class CTalentToolTip {

    CTalentToolTip()
    {
        m_toolTip = new ArrayList<String>();
    }

    public void addRank(String p_string)
    {
        m_toolTip.add(p_string);
    }
    
    public String getToolTip(int p_points)
    {
        if (m_toolTip.size() == 1)
        {
            return m_toolTip.get(0);
        }

        if (p_points > m_toolTip.size() - 1)
        {
            return m_toolTip.get(m_toolTip.size() - 1);
        }
        else if (p_points == 0)
        {
           return m_toolTip.get(0);
        }
        else
        {
            return m_toolTip.get(p_points - 1);
        }
    }

    public String buildToolTip(CTalent p_talent)
    {
        String l_buildString = "<html><b>" + p_talent.getName() + "</b><BR>" +
                "Rank: " + p_talent.getCurrentPoints() + "/" + p_talent.getMaxPoints() + "<BR>";
        if (p_talent.getTier() > 1)
        {
                l_buildString += "<span style=color:eb0504>Requires " + p_talent.getRequiredPoints() + " points in " + p_talent.getTree() + " Talents</span><BR>";
        }
        
        if (p_talent.getDependency() != null)
        {
            l_buildString += "<span style=color:eb0504>Requires " + p_talent.getTalentClass().getTalent(p_talent.getDependency()).getMaxPoints() + " points in " + p_talent.getDependency() + "</span><BR>";
        }
          
        l_buildString += getToolTip(p_talent.getCurrentPoints());

        if (p_talent.getMaxPoints() > 1 &&
                p_talent.getCurrentPoints() > 0 &&
                p_talent.getCurrentPoints() != p_talent.getMaxPoints())
        {
            l_buildString += "<BR><BR>Next Rank:<BR>" + getToolTip(p_talent.getCurrentPoints() + 1);
        }
                
        l_buildString += "</html>";
        return l_buildString;
    }
    
    private ArrayList<String> m_toolTip;
}
